package dmitrygusev.ratings.utils;

import java.io.InputStream;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Config {

	private static final Logger logger = Logger.getLogger(Config.class);
	private final Properties properties = new Properties();
	
	public Config() {
		try {
			InputStream is = null;
			try {
				is = getClass().getResourceAsStream(
						getClass().getSimpleName() + ".properties");
				properties.load(is);
			} finally {
				if (is != null) {
					is.close();
				}
			}
		}
		catch (Exception e) {
			logger.error("Failed to load config file: " + e);
		}
	}
	
	public String getProperty(String key) {
		return properties.containsKey(key) ? properties.getProperty(key) : null;
	}
}
